package www.wxwnb.clerk.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import www.wxwnb.clerk.R;
import www.wxwnb.clerk.http.entity.MsgQueryBean;
import www.wxwnb.clerk.ui.activity.ReviewActivity;
import www.wxwnb.clerk.ui.activity.ReviewDetailActivity;
import www.wxwnb.clerk.utils.TimeUtil;

public class MsgQueryAdapter extends RecyclerView.Adapter<MsgQueryAdapter.MsgViewHodler> {

    public static final String ID = "id";

    private Context mContext;
    private LayoutInflater mLayoutInflater;
    private List<MsgQueryBean.DataBean.PageRecordsBean> mDataList = new ArrayList<>();

    public MsgQueryAdapter(Context context, List<MsgQueryBean.DataBean.PageRecordsBean> list) {
        super();
        mContext = context;
        mLayoutInflater = LayoutInflater.from(context);
        mDataList = list;
    }

    public void setData(List<MsgQueryBean.DataBean.PageRecordsBean> list) {
        mDataList = list;
        notifyDataSetChanged();
    }

    @Override
    public MsgViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MsgViewHodler(mLayoutInflater.inflate(R.layout.adapter_msg_query, parent, false));
    }

    @Override
    public void onBindViewHolder(MsgViewHodler holder, int position) {
        MsgQueryBean.DataBean.PageRecordsBean b = mDataList.get(position);
        holder.one.setText("审核时间：" + TimeUtil.timestamp2DateOrString(b.getCreateTime()));
        holder.bottomOne.setText("审核信息：" + b.getMessage());
    }

    @Override
    public int getItemCount() {
        return mDataList == null ? 0 : mDataList.size();
    }

    class MsgViewHodler extends RecyclerView.ViewHolder {

        private LinearLayout item;
        private TextView one, bottomOne;

        public MsgViewHodler(View itemView) {
            super(itemView);
            item = itemView.findViewById(R.id.recycler_item);
            one = itemView.findViewById(R.id.tv_1);
            bottomOne = itemView.findViewById(R.id.tv_bottom_1);

           /* item.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, ReviewDetailActivity.class);
                    intent.putExtra(ID, mDataList.get(getAdapterPosition()).getId());
                    mContext.startActivity(intent);
                }
            });*/

        }
    }

}
